{% extends "master.html" %}
{% block subtitle %} - 出入库管理 - 更新入库单{% endblock %}

{% block extCSS %}
<style type="text/css">
    .template,.atmtemplate{
        display : none;
    }
</style>
{% endblock %}


{% block extJS %}
<script src="{{url_for('static', filename='js/customize/ivtnt_edit.js')}}" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toSubmit(){
        $("form").submit()   
    }
    
    function toCancel(){
        redirect_alert("{{MSG_LEAVE_WITHOUT_SAVING}}","{{url_for('bpIvtnt.view')}}")
    }  

//]]>
</script>
{% endblock %}


{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpRoot.view')}}">主面板</a></li>
          <li><a href="{{url_for('bpIvtnt.view')}}">出入库管理</a></li>
          <li class="active">更新入库单</li>
        </ol>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><a class="btn btn-default" data-toggle="modal" href="#pdtModal">添加商品</a></div>
            <div class="btn-group"><button class="btn btn-primary" onclick="toSubmit()">{{BTN_SUBMIT}}</button></div>
            <div class="btn-group"><button class="btn btn-inverse" onclick="toCancel()">{{BTN_CANCEL}}</button></div>
        </div>
    </div>
    <div class="row">    
        <form class="form-horizontal" method='POST' action="{{url_for('.view',action='update')}}" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{{obj.id}}"/>
        <input type="hidden" name="direction" value="IVTNT_IN"/>
        <fieldset>
            <legend>入库单详情</legend>
            <div class="col-md-6">
                <div class="control-group controls-row">
                    <label for="remark" class="control-label"><label for="refer">涉及</label></label>
                    <div class="controls"><input type="text" name="refer" id="refer" value="{{obj.refer|f}}"/></div>
                </div>
                <div class="control-group controls-row">
                    <label for="remark" class="control-label"><label for="remark">备注</label></label>
                    <div class="controls"><textarea name="remark" id="remark">{{obj.remark|f}}</textarea></div>
                </div>
            </div>   
            <div class="col-md-6">
                <div class="control-group controls-row">
                    <label for="remark" class="control-label"><label for="createTime">开单时间</label></label>
                    <div class="controls"><input type="text" name="createTime" id="createTime" class="datepicker" value="{{obj.createTime|fd}}"/></div>
                </div>
                <div class="control-group controls-row">
                    <label for="remark" class="control-label"><label for="createTime">经办人</label></label>
                    <div class="controls"><input type="text" value="{{session['user_profile']['name']}}" readonly="true"/></div>
                </div>
                <div class="control-group controls-row">
                  <label class="control-label" for="attachment">附件</label>
                  <div class="controls">
                      <ul id="atmul" class="list-unstyled">
                          <li><input type="file" name="atm_10"/><a href="#" onclick="addAtm('atmtemplate','atmmk','#atmul')"><i class="glyphicon glyphicon-plus"></i></a></li>
                          <li class="atmtemplate"><input type="file" name="atm_x"/><a href="#" onclick="delAtm(this,'atmmk')"><i class="glyphicon glyphicon-minus"></i></a></li>
                      </ul>
                  </div>
                </div>
            </div>
        </fieldset>
            
                                  

        <table class="table table-bordered">
            <thead>
                <tr>
                    <td>商品编号</td>
                    <td>条码</td>
                    <td>商品名称</td>
                    <td>类型</td>
                    <td>数量</td>
                    <td>备注</td>
                </tr>
            </thead>
            <tbody id="pdtlist">
                {% for d in obj.dtls %}
                    <tr>               
                        <td>{{d.pdt.no}}<input type="hidden" name="oldproduct_{{d.id}}" value="{{d.id}}"/></td>
                        <td>{{d.pdt.barcode|f}}</td>
                        <td>{{d.pdt.name}}</td>
                        <td>{{d.pdt.type|f}}</td>
                        <td><input type="text" name="oldqty_{{d.id}}" value="{{d.qty}}" class="num col-md-1"/></td>
                        <td><textarea name="oldremark_{{d.id}}">{{d.remark|f}}</textarea></td>
                    </tr>
                {% endfor %}
            </tbody>                
        </table>
        
        </form>
    </div>
</div>
    



<!-- modal begin -->
<div id="pdtModal" class="modal hide fade" tabindex="-1" data-width="860" aria-hidden="true" style="display: none;">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h5>查询商品</h5>
  </div>
  <div class="modal-body">
    <div class="row">
        <span class="col-md-3">
            <div class="control-group controls-row">
                <label class="control-label" for="pdtno"><label for="pdtno">系统编号</label></label>
                <div class="controls"><input id="pdtno" type="text" value=""></div>
            </div>
        </span>
        <span class="col-md-3">
            <div class="control-group controls-row">
                <label class="control-label" for="pdtname"><label for="pdtname">商品名称</label></label>
                <div class="controls"><input id="pdtname" type="text" value=""></div>
            </div>
        </span>
        <span class="col-md-3">
            <div class="control-group controls-row">
                <label class="control-label" for="pdttypeID"><label for="pdttypeID">商品类型</label></label>
                <div class="controls">
                    <select id="pdttypeID">
                        <option value=""></option>
                        {% for p in getMaster('ProductType') %}
                            <option value="{{p.id}}">{{p}}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
        </span>
    </div>
    <div class="row">    
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button type="button" class="btn btn-default" onclick="ajaxSrhPdt()">查询记录</button></div>            
        </div>
    </div>                    
    <div>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <td><input type="checkbox" onclick="selectall(this,'srhpdt')"/></td>
                    <td>系统编号</td>
                    <td>商品名称</td>
                    <td>商品类型</td>
                </tr>
            </thead>
            <tbody id="srhbody">
                
            </tbody>
        </table>
        
    </div>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-primary" onclick="checkAndAdd()">添加</button>
    <button type="button" data-dismiss="modal" class="btn btn-inverse">取消</button>
  </div>
</div>
<!-- modal end -->



   
{% endblock %}